//裸钻筛选页面
var PlaceOrder=false;//代下单
//时间的
var calendarDateFormat = myApp.calendar({
    input: '#PurchaseTime',
     monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
    input: '#ArrivalTime',
     monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var weightType; //切换重量的
var arrIndex=[];//重量

var isShowCut=false;//是否显示切工
(function(){
	var dia={
		init:function(){
			args = GetUrlParms();				
			if(args["team"]!=undefined){						
				 TEAM = args["team"];//2是现货					
			} 
			if(args["cid"]!=undefined){						
				 Customer_id = args["cid"];	
				 PlaceOrder=true;
			} 
			this.bindEvents();

            weightType=  localStorage.getItem('weightType');
            if(weightType=='big'){
                $('#switch_icons').attr("data-type","big");
                $('#switch_icons').addClass('big_weight');
                $("#search_weight_big").show();
                $("#search_weight_small").hide();
            }
		},
		bindEvents:function(){
			var self=this;

			self.typeChange(0);//默认显示白钻
			 if(TEAM!=0){
                if(isHideSupplier == "1"){
                    var $supplier=['<div class="term">'+
                                '<h4>'+_("供应商")+'</h4>'+
                                '<input type="text" class="cert-num" placeholder="'+_("请输入供应商")+'" id="supplierName" />'+
                            '</div>'].join('');
                }
                    var $PurchaseSupplier=['<div class="term">'+
                                '<h4>'+_("原供应商")+'</h4>'+
                                '<input type="text" class="cert-num" placeholder="'+_("请输入原供应商")+'" id="PurchaseSupplierName" />'+
                            '</div>'].join('');


				var $sn=[	'<div class="term" id="sn_num_box">'+
							'<h4>'+_("货号")+'</h4>'+
							'<input type="text" class="cert-num" placeholder="'+_("请输入货号")+'" id="sn_num" />'+
						'</div>'].join('');
				//团队端现货和订货
                 if(isHideSupplier == "1"){
                     var $spot=['<div id="Exists" class="term">' +
                     '<span  class="Existing"  id="ExistingId">现货</span>' +'<span   class="Exist" id="ExistId">订货</span>'+
                     '</div>'].join('');
                 }

				if(TEAM==2){
					    $("#originSn_box").after($PurchaseSupplier+$sn);
				}else{
				    if(isHideSupplier == "1"){
					    $("#originSn_box").after($supplier+$sn+$spot);
                    }else{
                        $("#originSn_box").after($sn);
                    }
				}
            }

			 if(TEAM==2){//现货
			 	$("#stock_box").show();
			 	$("#stocks_PurchaseTime,#stocks_ArrivalTime").show();
			 	//状态
			 	jsonType=stock;
				var $Status="<h4>"+_("货品状态")+"</h4>";
				for(var j=0;j<jsonType[1].Status.length;j++){
					$Status += '<span data-value="'+jsonType[1].Status[j][0]+'">'+ _(jsonType[1].Status[j][1]) +'</span>';
				}
				$("#status_box").html($Status);
				
			 }else{
			 	$("#stock_box").hide();
			 	$("#stocks_PurchaseTime,#stocks_ArrivalTime").hide();
			 }

            // //筛选现货
            // $("#Exists span").on('click',function(){
            //     $(this).toggleClass("active").siblings().removeClass("active");
            //
            // })
            //大重量 小重量
            //切换大重量和小重量搜索
            $("#switch_icons").on("click",function(){
                var rebate_type=$(this).attr("data-type");
                var weight_list=localStorage.getItem('weightList');
                if(weight_list){
                    weight_list=JSON.parse(weight_list);
                    var new_weight=[];
                    for(var j=0;j<weight_list.length;j++){
                        if(rebate_type=='small'){
                            new_weight.push(weight_list[j]+13);
                        }else {
                            new_weight.push(weight_list[j]-13);
                        }
                    }
                    weight_list=new_weight;
                    localStorage.setItem('weightList',JSON.stringify(new_weight))
                }
                if(rebate_type=='small'){
                    $(this).attr("data-type","big");
                    $('#switch_icons').addClass('big_weight');
                    localStorage.setItem('weightType','big');
                    $("#search_weight_big").show();
                    $("#search_weight_small").hide();
                }else if(rebate_type=='big'){
                    $(this).attr("data-type","small");
                    $('#switch_icons').removeClass('big_weight');
                    localStorage.setItem('weightType','small');
                    $("#search_weight_big").hide();
                    $("#search_weight_small").show();
                }


                //切换重量保留上一次的选中的重量范围start
                rebate_type=rebate_type=='small'?'big':'small';
                $("#weight_box span").removeClass('active');
                if(weight_list.length>=1){
                    for(var j=0;j<weight_list.length;j++){
                        $("#weight_box span").eq(weight_list[j]).addClass('active');
                    }
                }
                var weightSelected =  $("#weight_box span.active");
                if (weightSelected.length == 1) {
                    $("#weight-min").val(weightSelected.attr("data-value").split("-")[0]);
                    $("#weight-max").val(weightSelected.attr("data-value").split("-")[1]);
                }
                else if (weightSelected.length > 1) {
                    var min = weightSelected[0];
                    var max = weightSelected[weightSelected.length - 1];
                    $("#weight-min").val($(min).attr("data-value").split("-")[0]);
                    $("#weight-max").val($(max).attr("data-value").split("-")[1]);
                }



            });
			 //支付状态、上下架、状态
			 $("#paymentStatus span,#onshelves span,#status_box span").on("click",function(){
			 	$(this).toggleClass("active").siblings().removeClass("active");
			 });
			//筛选
            $("#show_term_btn").on("click", function () {
                $("#common_header").hide();
                $("#product_term_box").show();
            });
            $("#close_term_btn").on("click", function () {
                $("#common_header").show();
                $("#product_term_box").hide();
            });
            $("#product_type span").on("click", function () {
                $(this).toggleClass("active").siblings().removeClass("active");
                var type = $("#product_type span.active").attr("data-type");
                self.typeChange(type);
            });
            //其他筛选条件点击添加样式、可多选

            $("#product_term_box").on("click",".term span" ,function () {
                $(this).toggleClass("active");
                //筛选点击重量时，重量框的值
                var nameShape = $(this).parent().attr("data-type");
                var name = $(this).parent().parent().attr("data-type");
                if (name == "Weight") {
                    self.getWeight();
                }
                if(nameShape == "Shape"){
                    self.getShape();
                }
            });
            $("#filter_product_btn").on("click", function () {
                indexCount=1;
                $("#stock_body").html('');
                 self.getQueryParameters();
            });
            //重置
            $("#reset_term_btn").on("click",function(){
                self.resetParameters();
            });
            //手动输入重量时移出选中的重量
            $("#weight-input").keypress(function () {
                $("#weight_box span").removeClass("active");//移除选中的重量的样式
            });
            //快速选择3ex
            $(".quick_choose span").on("click", function () {
                $(this).toggleClass("active").siblings().removeClass("active");
                self.quickChoose();
            });

            //筛选条件
            var diaList = localStorage.getItem("diaList")||'';
            if(diaList){
                self.oldSelect(diaList);
            }
		},
		//快速选择
        quickChoose:function(){
            var cut = $(".cut").children("span");
            var polish = $(".polish").children("span");
            var symmetry = $(".symmetry").children("span");
            var fluo = $(".fluorescence").children("span");
            cut.removeClass("active");
            symmetry.removeClass("active");
            fluo.removeClass("active");
            polish.removeClass("active");
            var choose = $(".quick_choose span.active").attr("data-choose");
            if (choose == 1) {
                cut.slice(0, 1).addClass("active");
                polish.slice(0, 1).addClass("active");
                symmetry.slice(0, 1).addClass("active");
                fluo.slice(0, 1).addClass("active");
            } if (choose == 2) {
                cut.slice(0, 1).addClass("active");
                polish.slice(0, 1).addClass("active");
                symmetry.slice(0, 1).addClass("active");
            } if (choose == 3) {
                cut.slice(0, 2).addClass("active");
                polish.slice(0, 2).addClass("active");
                symmetry.slice(0, 2).addClass("active");
            } if (choose == 4) {
                cut.slice(0, 3).addClass("active");
                polish.slice(0, 3).addClass("active");
                symmetry.slice(0, 3).addClass("active");
            }
        },
        //白彩钻的筛选参数
        typeChange: function (type) {
            $("#color,#strength,#data_MilkysHues,#data_Hues").remove();
            if (type == 0) {
                var MilkysHues=['<div class="term white-term milkysHues" data-type="MilkysHues" id="data_MilkysHues">',
                   '<h4>'+_("奶色")+'</h4>',
                    '<span data-value="none">'+_("无奶")+'</span>',
                    '<span data-value="light">'+_("带奶")+'</span>',
                    '<span data-value="other">'+_("待查")+'</span>',
                '</div>',
                '<div class="term white-term milkysHues" data-type="Hues" id="data_Hues">',
                    '<h4>'+_("咖色")+'</h4>',
                    '<span data-value="none">'+_("无咖")+'</span>',
                    '<span data-value="light">'+_("带咖")+'</span>',
                    '<span data-value="other">'+_("待查")+'</span>',
                '</div>',
                ].join('');
                $("#cert").after(MilkysHues);


                var color = ['<div class="term color" data-type="Color" id="color">',
                    '<h4>'+_("颜色")+'</h4>',
                    '<span data-val="D">D</span>',
                    '<span data-val="E">E</span>',
                    '<span data-val="F">F</span>',
                    '<span data-val="G">G</span>',
                    '<span data-val="H">H</span>',
                    '<span data-val="I">I</span>',
                    '<span data-val="J">J</span>',
                    '<span data-val="K">K</span>',
                    '<span data-val="L">L</span>',
                    '<span data-val="M">M</span>',
                    '<span data-val="N">N</span>',
                    '<span data-val="O-Z">O-Z</span>',
                    '<span data-val="NN">NN</span>',
                    '</div>'].join('');
                $("#weight-input").after(color);
            } if (type == 1) {
                var color = ['<div class="term color" data-type="FancyColor" id="color">',
                  '<h4>'+_("颜色")+'</h4>',
                  '<span data-value="yellow">'+_("黄色")+'</span>',
                  '<span data-value="pink">'+_("粉色")+'</span>',
                  '<span data-value="orange">'+_("橙色")+'</span>',
                  '<span data-value="green">'+_("绿色")+'</span>',
                  '<span data-value="gray">'+_("灰色")+'</span>',
                  '<span data-value="balck">'+_("黑色")+'</span>',
                  '<span data-value="brown">'+_("棕色")+'</span>',
                  '<span data-value="blue">'+_("蓝色")+'</span>',
                  '<span data-value="purple">'+_("紫色")+'</span>',
                  '<span data-value="other">'+_("其他")+'</span>',
                 '</div>'].join('');
                  var FancyStrength=['<div class="term color" data-type="FancyStrength" id="strength">',
                   '<h4>'+_("强度")+'</h4>',
                   '<span data-value="faint">'+_("轻微色")+'</span>',
                   '<span data-value="very light">'+_("非常淡")+'</span>',
                   '<span data-value="light">'+_("淡色")+'</span>',
                   '<span data-value="fancy light">'+_("淡彩")+'</span>',
                   '<span data-value="fancy">'+_("中彩")+'</span>',
                   '<span data-value="fancy intense">'+_("浓彩")+'</span>',
                   '<span data-value="fancy vivid">'+_("艳彩")+'</span>',
                   '<span data-value="fancy dark">'+_("暗彩")+'</span>',
                   '<span data-value="fancy deep">'+_("深彩")+'</span>',
                   '</div>'].join('');
                  $("#weight-input").after(color + FancyStrength);
            }
           

        },
        //获取参数
        getQueryParameters: function () {
            var result = {};
            // result.limit=500;
     		result.useDict=true;
            // var da=$("#weight-min").val()+'-'+$("#weight-max").val();

            //查询开始时间
            var dtSearchStart = new Date().getTime();
            //循环找出筛选框里选中的参数
            $("#product_term_box .term").each(function (i, item) {
                var jqControls = $(item);
                var datatype = jqControls.attr("data-type");//参数类型
                if (datatype) {
                    var tmpList = [];
                    if ($(item).find("span.active").length < $(item).find("span").length) {
                        $(item).find("span.active").each(function (j, p) {
                            if ($(p).attr("data-value")&&datatype != "Place") {//如果有data-value值的
                                tmpList.push($(p).attr("data-value"));//将选中的data-value值放入数组

                            }else if($(p).attr("data-value")&&datatype == "Place"){
                                if($(p).attr("data-value")!='mainland'&&$(p).attr("data-value")!='hk'&&$(p).attr("data-value")!='ind'){
                                    var ad=$(p).attr("data-value").split(',')
                                    ad.forEach(function (val) {
                                        tmpList.push(val)
                                    })
                                }else {
                                    tmpList.push($(p).attr("data-value"));
                                }
                            }
                            else {
                                if($(p).text()=="O-Z"){
		                    		 tmpList.push("O-P","Q-R","S-T","U-V","W-X","Y-Z");
		                    	}else if($(p).text()=="F" && datatype=="Fluorescence"){
		                    		tmpList.push("VSL","F");
		                    	}else{
		                    		tmpList.push($(p).text());
		                    	}
		                    }
                        });
                        if (tmpList.length > 0) {
                            if (datatype == "Place" || datatype == "MilkysHues" || datatype == "Hues") {
                                if (!result["alias"])
                                    result["alias"] = {}; //初始化
                                if (datatype == "Place") {
                                    result["alias"].Place = tmpList;
                                }
                                else if (datatype == "MilkysHues") {
                                    // result["alias"].Hue = tmpList;
                                    result["alias"].Milky = tmpList;//解决奶咖选无时奶无效的问题{"alias": {"Milky": ["none"], "Hue": ["none"]}}
                                }else if(datatype == "Hues"){
                                    result["alias"].Hue = tmpList;
                                }else if(datatype == "MilkysHues" && datatype == "Hues"){
                                    result["alias"].Milky = tmpList;
                                    result["alias"].Hue = tmpList;
                                }
                            } else if(datatype=='Weight'){
                                tmpList=[];
                                if ($("#weight-min").val() != ""&&$("#weight-max").val() != "") {
                                    var weit=$("#weight-min").val()+'-'+$("#weight-max").val();
                                    if(tmpList.indexOf(weit)==-1){
                                        tmpList.push(weit)
                                    }
                                }
                                result[datatype] = tmpList;
                            }
                            else
                                result[datatype] = tmpList;
                        }

                    }

                }
            });
            result.IsFancy =Number($("#product_type").find("span.active").attr("data-type"));//获取选中的钻石类型
			if(TEAM!=2){
				result.OnShelves = 1;
			}
            
            //重量输入框不为空时，获取里面的值
            if ($("#weight-min").val() != "") {
                result.WeightMin = $("#weight-min").val();
            }
            if ($("#weight-max").val() != "") {
                result.WeightMax = $("#weight-max").val();
            }
             if ($("#originSn").val() != ""){ //为空的话不要这个参数
             	var OriginSNVal = trimStr($("#originSn").val());
        		result.OriginSN=OriginSNVal; 
            }
            if ($("#certsNum").val() != ""){ //为空的话不要这个参数
            	var CertNoVal = trimStr($("#certsNum").val());
            	console.log(CertNoVal)
        		result.CertNo=CertNoVal; 
			}
			if(TEAM!=0){
			    if(isHideSupplier == "1"){
                    if(TEAM!=2){//现货不是供应商，是原供应商
                        if ($("#supplierName").val() != "")  //为空的话不要这个参数
                        {
                            var arr = new Array(0)
                            arr[0]=$("#supplierName").val();
                            result.Supplier = arr;
                        }
                    }
                }

				if ($("#sn_num").val() != "")  //为空的话不要这个参数
				result.SN = $("#sn_num").val();
			}
            if ($(".exiting").hasClass("active")) {//不选中的话不要现货的参数
            	//选中
        		delete result.Supplier;
                result.IsStock = 0;// 1现货搜索
            }

            if($('.Existing').hasClass("active")){
                //选中
                delete result.Supplier;
                result.IsStock = 0;// 1现货搜索
            }

            if($('.Exist').hasClass("active")){
                //选中
                delete result.Supplier;
                result.IsExclude = 1;// 1订货搜索
            }


			if(TEAM==0){
				var url_href="/Customer/WhiteDias?team=0";//客户端的页面
			}else if(TEAM==1){
				var url_href="/Team/WhiteDias?team=1";//团队端的页面
			}else if(TEAM==2){
				result.ReceiptStatus=$("#paymentStatus span.active").attr("data-value");//已付未付
				result.OnShelves=$("#onshelves span.active").attr("data-value");//上架下架
				result.Status=$("#status_box span.active").attr("data-value");//货品状态
				if($("#PurchaseSupplierName").val()!=""){
					result.PurchaseSupplier=$("#PurchaseSupplierName").val();//原供应商
				}	
				var PurchaseTime=$("#stocks_PurchaseTime").val();
				var ArrivalTime=$("#stocks_ArrivalTime").val();
				if(PurchaseTime!="")
					result.PurchaseTime=PurchaseTime;//买入时间
				if(ArrivalTime!="")
					result.ArrivalTime=ArrivalTime;//到货时间
				var url_href="/Team/MyDias?team=2";//团队端的现货页面
			}else if(TEAM==3){
				var url_href="/Team/WhiteDias?team=3&cid="+Customer_id+'&userName='+NullFormat(getUrlParam('userName'));//团队端的代下单
			}
			var action=url_href;
		  	form = $("<form method='post' id='params_form' action='"+action+"'>"+
		   	"<input type='text' value='"+JSON.stringify(result)+"' name='params'></form>")
			$("#form_box").html(form);
			$("#params_form").submit();

			//筛选条件
            if(result!='{"IsFancy":0,"limit":200,"useDict":true,"OnShelves":"1"}'){
                if(result.CertNo){  //证书号
                    result.CertNo=result.CertNo.split(' ');
                }
                if(result.OriginSN){ //原货号
                    result.OriginSN=result.OriginSN.split(' ');
                }

                localStorage.setItem("diaList",JSON.stringify(result))
            }else {
                localStorage.removeItem("diaList");
            }
        },
        //重置参数
        resetParameters:function(){
            $('.quick_choose span').removeClass('active');//清空快速选择
            $(".term span").removeClass("active"); //清楚选中
            $('.term input').val(''); //清楚输入框
            localStorage.setItem("weightList",'');
        },
        //获取重量
        getWeight: function () {
            var weightSelected = $(".weight span.active");//选中的重量

            //选中大小重量start
            arrIndex=[];
            if(weightSelected.length>=1){
                for(var k=0;k<$('#weight_box span').length;k++){
                    if($('#weight_box span').eq(k).hasClass('active')){
                        arrIndex.push(k);
                    }
                }
                console.log(arrIndex)
            }
            //选中大小重量end

            //筛选选中重量start
            // var arr=[];
            // for(var i=0;i<$('#weight_box span').length;i++){
            //     if($('#weight_box span').eq(i).hasClass('active')){
            //         arr.push(i);
            //     }
            // }
            localStorage.setItem("weightList",JSON.stringify(arrIndex));
            //筛选选中重量end


            if (weightSelected.length == 1) {//如果只选择一个
                $("#weight-min").val(weightSelected.attr("data-value").split("-")[0]);
                $("#weight-max").val(weightSelected.attr("data-value").split("-")[1]);
            }
            else if (weightSelected.length > 1) {//选择多个
                var min = weightSelected[0];//选中的序列中的第一个的值
                var max = weightSelected[weightSelected.length - 1];//选中的序列中的最后一个的值
                $("#weight-min").val($(min).attr("data-value").split("-")[0]);//绑值
                $("#weight-max").val($(max).attr("data-value").split("-")[1]);
            } else {
                $("#weight-min").attr("value");
                $("#weight-max").attr("value");
                // $("#weight-min").val('');
                // $("#weight-max").val('');
            }



        },

        getShape:function(){
            var roundSelected = $(".shape[data-type='Shape'] span:eq(0)").hasClass('active');
            var roundOtherSelected = $(".shape[data-type='Shape'] span").hasClass('active');
            if (roundSelected==false && roundOtherSelected==true) {
                $(".cut[data-type='Cut']").hide(); //round cut hide
                isShowCut = false;//不显示切工搜索
            }
            else {
                $(".cut[data-type='Cut']").show(); //round cut show
                isShowCut = true;//显示切工搜索
            }

        },
        //恢复历史已选中条件start
        oldSelect:function (data) {
            var self=this;
            var oldData=JSON.parse(data);
            $('#product_term_box').find('div').find('span').removeClass('active');
            // $('#product_type').find('span').eq(0).addClass('active');
            //重量
            $('#weight-min').val(oldData.WeightMin);
            $('#weight-max').val(oldData.WeightMax);
            if(localStorage.getItem("weightList")){
                var weightLi=JSON.parse(localStorage.getItem("weightList"))
                for(var j=0;j<weightLi.length;j++){
                    $('#weight_box span').eq(weightLi[j]).addClass('active')
                }
            }
            if(oldData.IsFancy==1){
                self.typeChange(1)
            }else {
                self.typeChange(0)
            }
            for(var name in oldData){//遍历对象属性名

                if(name=='IsFancy'){//钻石类型
                     $('#product_type').find('span[data-type="'+oldData[name]+'"]').addClass('active')
                }
                if(name=='Shape' ){//形状
                    for(var i=0;i<oldData[name].length;i++){
                        $('#product_term_box').find('div[data-type="'+name+'"]').find('span[data-value="'+oldData[name][i]+'"]').addClass('active')
                    }
                }
                if(name=='Color'){//白钻颜色
                    for(var i=0;i<oldData[name].length;i++){
                        $('body #product_term_box').find('div[data-type="Color"]').find('span[data-val="'+oldData[name][i]+'"]').addClass('active')
                    }
                }
                if(name=='FancyColor'){//彩钻颜色
                    for(var i=0;i<oldData[name].length;i++){
                        $('body #product_term_box').find('div[data-type="FancyColor"]').find('span[data-value="'+oldData[name][i]+'"]').addClass('active')
                    }
                }
                if(name=='FancyStrength'){//彩钻强度
                    for(var i=0;i<oldData[name].length;i++){
                        $('body #product_term_box').find('div[data-type="FancyStrength"]').find('span[data-value="'+oldData[name][i]+'"]').addClass('active')
                    }
                }
                if(name=='alias' ){//奶咖、地区
                    if(oldData[name].Place){
                        for(var i=0;i<oldData[name].Place.length;i++){
                            $('#product_term_box').find('div[data-type="Place"]').find('span[data-value="'+oldData[name].Place[i]+'"]').addClass('active')
                        }
                    }
                    if(oldData[name].Milky){
                        for(var i=0;i<oldData[name].Milky.length;i++){
                            $('#product_term_box').find('div[data-type="MilkysHues"]').find('span[data-value="'+oldData[name].Milky[i]+'"]').addClass('active')
                        }
                    }
                    if(oldData[name].Hue){
                        for(var i=0;i<oldData[name].Hue.length;i++){
                            $('#product_term_box').find('div[data-type="Hues"]').find('span[data-value="'+oldData[name].Hue[i]+'"]').addClass('active')
                        }
                    }

                }
                if(name=='Clarity' || name=='Cut'|| name=='Polish'|| name=='Symmetry'|| name=='Fluorescence'|| name=='CertType'){
                    for(var i=0;i<oldData[name].length;i++){
                        $('#product_term_box').find('div[data-type="'+name+'"]').find('span[data-val="'+oldData[name][i]+'"]').addClass('active')
                    }
                }
                if(name=='CertNo' ){
                    $('#certsNum').val(oldData.CertNo);
                }
                if(name=='OriginSN' ){
                    $('#originSn').val(oldData.OriginSN);
                }
                if(name=='Supplier' ){
                    $('#supplierName').val(oldData.Supplier[0]);
                }
                if(name=='SN' ){
                    $('#sn_num').val(oldData.SN);
                }
                if(name=='IsStock'){
                    $("body #product_term_box").find('#ExistingId').addClass('active')
                }
                if(name=='IsExclude'){
                    $("body #product_term_box").find('#ExistId').addClass('active')
                }

                //现货
                if(name='ReceiptStatus'){ //支付状态
                    $("#product_term_box").find('#paymentStatus').find('span[data-value="'+oldData[name]+'"]').addClass('active')
                }
                if(name='OnShelves'){ //上下架状态
                    $("#product_term_box").find('#onshelves').find('span[data-value="'+oldData[name]+'"]').addClass('active')
                }
                if(name='Status'){ //货品状态
                    $("#product_term_box").find('#status_box').find('span[data-value="'+oldData[name]+'"]').addClass('active')
                }

            }
            //恢复历史已选中条件end



        }
	}
	dia.init();
})();
//去掉首尾空格
function trimStr(str){
	return str.replace(/(^\s*)|(\s*$)/g,"");
}
//去掉数组里的空值
Array.prototype.clean = function(deleteValue) {  
  for (var i = 0; i < this.length; i++) {  
    if (this[i] == deleteValue) {           
      this.splice(i, 1);//返回指定的元素  
      i--;  
    }  
  }  
  return this;  
};

